<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<script type="text/javascript">
    var rowId = 0;
    
    $('.ui-reset , #refresh_creditinvGrid').click(function(){
        $("#creditinvGrid").jqGrid('setGridParam',{search:false});
        var postData = $("#creditinvGrid").jqGrid('getGridParam','postData');
        $.extend(postData,{searchField:"",searchString:"",searchOper:""});
        $.extend(postData,{filters:""});
        $("#creditinvGrid").trigger("reloadGrid");
    });
    
    $.subscribe('creditinvGridRowSelected', function(event,data) {
        rowId = event.originalEvent.id;
        $( "#creditinvGrid_edit" ).button( "option", "disabled", false );
    });

    $.subscribe('searchCreditinvGrid', function(event,data) {
        $("#creditinvGrid").jqGrid('searchGrid', {drag:true,closeAfterSearch:true,closeOnEscape:true,sopt:['eq'],caption:"Search Employee"} );
    });
    
    $.subscribe('creditinvGridComplete',function(event,data){
        $( "#creditinvGrid_search" ).button( "option", "disabled", false );
        $( "#creditinvGrid_showhide" ).button( "option", "disabled", false );
    });
    
    $.subscribe('showhideCreditinvGrid', function(event,data) {
        $("#creditinvGrid").jqGrid('setColumns',{});
    });
    
    $.subscribe('editCreditinvGrid', function(event,data) {
        if(rowId!=0){
            $("#creditinvGrid").jqGrid('editGridRow',rowId,{resize:true,drag:true,closeOnEscape:true,closeAfterEdit:true,jqModal:true,width:350,left:310,top:20,reloadAfterSubmit:true,afterSubmit:function(response, postdata) {return isError(response.responseText);}});
        }else{
            alert("Sorry. Please select a credit investigation first.");
        }
    });
    
    function isError(text) {
        if(text.indexOf('ERROR') >= 0) { return [false, text]; }
        return [true,''];
    }
    
</script>
<div class="gridOptsContainer">
    <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="creditinvGrid_search" onClickTopics="searchCreditinvGrid" value="Search Credit Investigation"/>
    <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="creditinvGrid_showhide" onClickTopics="showhideCreditinvGrid" value="Show/Hide Columns"/>
    <s:if test="#session.branch.branchname!='Head Office'">
        <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="creditinvGrid_edit" onClickTopics="editCreditinvGrid" value="Edit CI"/>
    </s:if>
</div>
<s:url id="remoteurl" action="grid-creditinv"/>
<s:url id="editurl" action="edit-creditinvestigation"/>
<sjg:grid
    id="creditinvGrid"
    caption="Cashmate Credit Investigations"
    dataType="json"
    href="%{remoteurl}"
    editurl="%{editurl}"
    gridModel="gridModel"
    pager="true"
    pagerButtons="true"
    pagerInput="true"
    rowList="15,30,50"
    rowNum="15"
    loadingText="Requesting Data..."
    width="970"
    shrinkToFit="false"
    hoverrows="true"
    rownumbers="true"
    autoencode="true"
    viewrecords="true"
    navigator="true"
    navigatorAdd="false"
    navigatorDelete="false"
    navigatorEdit="false"
    navigatorSearch="true"
    navigatorView="true"
    onSelectRowTopics="creditinvGridRowSelected"
    onGridCompleteTopics="creditinvGridComplete"
    >

    <sjg:gridColumn name="creditinvid"
                    key="true"
                    index="creditinvid"
                    title="creditinvid"
                    sortable="false"
                    hidden="true"
                    align="center"
                    />

    <sjg:gridColumn name="documentno"
                    index="documentno"
                    title="Document No."
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="idnumber"
                    index="idnumber"
                    title="Employee ID"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="loanappdocumentno"
                    index="loanappdocumentno"
                    title="Loan Application Document"
                    sortable="true"
                    search="true"
                    align="center"
                    />

    <sjg:gridColumn name="investigationdate"
                    index="investigationdate"
                    title="Investigation Date"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />
    
    <sjg:gridColumn name="nickname"
                    index="nickname"
                    title="Nickname"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="presentaddressstatus"
                    index="presentaddressstatus"
                    title="Present Address Status"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addressfloorarea"
                    index="addressfloorarea"
                    title="Address Floor Area"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addresslotarea"
                    index="addresslotarea"
                    title="Address Lot Area"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addressstability"
                    index="addressstability"
                    title="Address Stability"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addressmodel"
                    index="addressmodel"
                    title="Address Model"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addressmake"
                    index="addressmake"
                    title="Address Make"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addressland"
                    index="addressland"
                    title="Address Land"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addressmonthlyrental"
                    index="addressmonthlyrental"
                    title="Address Monthly Rental"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addresslandlordname"
                    index="addresslandlordname"
                    title="Address Landlord Name"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addresslandlordaddress"
                    index="addresslandlordaddress"
                    title="Address Landlord Address"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="addresslandlordphoneno"
                    index="addresslandlordphoneno"
                    title="Address Landlord Contact No."
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="spousedegree"
                    index="spousedegree"
                    title="Spouse Degree"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="spouseschool"
                    index="spouseschool"
                    title="Spouse School"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="spouseyeargraduated"
                    index="spouseyeargraduated"
                    title="Spouse Year Graduated"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="previousstreetaddress"
                    index="previousstreetaddress"
                    title="Previous Street Address"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="previousbarangay"
                    index="previousbarangay"
                    title="Previous Barangay"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="previouscityormunicipality"
                    index="previouscityormunicipality"
                    title="Previous City"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="previousprovince"
                    index="previousprovince"
                    title="Previous Province"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="previouspostalcode"
                    index="previouspostalcode"
                    title="Previous Postal Code"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="previouslengthofstayinyears"
                    index="previouslengthofstayinyears"
                    title="Previous Length of Stay (years)"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="previouslengthofstayinmonths"
                    index="previouslengthofstayinmonths"
                    title="Previous Length of Stay (months)"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsstreetaddress"
                    index="parentsstreetaddress"
                    title="Parent's Street Address"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsbarangay"
                    index="parentsbarangay"
                    title="Parent's Barangay"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentscityormunicipality"
                    index="parentscityormunicipality"
                    title="Parent's City"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsprovince"
                    index="parentsprovince"
                    title="Parent's Province"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentspostalcode"
                    index="parentspostalcode"
                    title="Parent's Postal Code"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentslengthofstayinyear"
                    index="parentslengthofstayinyear"
                    title="Parent's Length of Stay (year)"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentslengthofstayinmonths"
                    index="parentslengthofstayinmonths"
                    title="Parent's Length of Stay (months)"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="fatherinlawfirstname"
                    index="fatherinlawfirstname"
                    title="Father-in-law Firstname"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="fatherinlawmiddlename"
                    index="fatherinlawmiddlename"
                    title="Father-in-law Middle Name"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="fatherinlawlastname"
                    index="fatherinlawlastname"
                    title="Father-in-law Last Name"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="motherinlawfirstname"
                    index="motherinlawfirstname"
                    title="Mother-in-law First Name"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="motherinlawmiddlename"
                    index="motherinlawmiddlename"
                    title="Mother-in-law Middle Name"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="motherinlawlastname"
                    index="motherinlawlastname"
                    title="Mother-in-law Last Name"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="fatherinlawemployer"
                    index="fatherinlawemployer"
                    title="Father-in-law Employer"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="motherinlawemployer"
                    index="motherinlawemployer"
                    title="Mother-in-law Employer"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="fatherinlawposition"
                    index="fatherinlawposition"
                    title="Father-in-law Position"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="motherinlawposition"
                    index="motherinlawposition"
                    title="Mother-in-law Position"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="fatherinlawage"
                    index="fatherinlawage"
                    title="Father-in-law Age"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="motherinlawage"
                    index="motherinlawage"
                    title="Mother-in-law Age"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsinlawstreetaddress"
                    index="parentsinlawstreetaddress"
                    title="Parents-in-law Street Address"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsinlawbarangay"
                    index="parentsinlawbarangay"
                    title="Parents-in-law Barangay"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsinlawcityormunicipality"
                    index="parentsinlawcityormunicipality"
                    title="Parents-in-law City"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsinlawprovince"
                    index="parentsinlawprovince"
                    title="Parents-in-law Province"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsinlawpostalcode"
                    index="parentsinlawpostalcode"
                    title="Parents-in-law Postal Code"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsinlawlengthofstayinyears"
                    index="parentsinlawlengthofstayinyears"
                    title="Parents-in-law Length of Stay (years)"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="parentsinlawlengthofstayinmonths"
                    index="parentsinlawlengthofstayinmonths"
                    title="Parents-in-law Length of Stay (months)"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="presentaddresslengthofstayinyears"
                    index="presentaddresslengthofstayinyears"
                    title="Present Address Length of Stay (years)"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="presentaddresslengthofstayinmonths"
                    index="presentaddresslengthofstayinmonths"
                    title="Present Address Length of Stay (months)"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="stocksworthamount"
                    index="stocksworthamount"
                    title="Stocks Worth Amount"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    align="center"
                    />
    
    <sjg:gridColumn name="stocksworthdescription"
                    index="stocksworthdescription"
                    title="Stocks Worth Description"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'500'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="remarks"
                    index="remarks"
                    title="Remarks"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'500'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="creditconsultantrecommendation"
                    index="creditconsultantrecommendation"
                    title="Credit Consultant Recommendation"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'500'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="branchmanagerrecommendation"
                    index="branchmanagerrecommendation"
                    title="Branch Manager Recommendation"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'500'}"
                    align="center"
                    />
    
    <sjg:gridColumn name="areamanagerrecommendation"
                    index="areamanagerrecommendation"
                    title="Area Manager Recommendation"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'500'}"
                    align="center"
                    />
    
    <!-- WOHOO -->
    
</sjg:grid>
